home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 3.1 KB | 123 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LClipPicture.cp ©1993-1998 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // Displays a 'PICT' resource
- //
- // LClipPicture stores the ID of a PICT resource as a member variable, and
- // always calls GetPicture() to get a Handle to the picture. It purposely
- // does not release the PICT resource when deleted, since other LClipPicture
- // views may be using the same picture. For example, you might use the
- // same picture as a background or graphic element in multiple windows.
- //
- // If you are concerned about the memory used by the PICT resource, mark
- // it as purgeable in your resource file.
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- #include "LClipPicture.h"
- #include <LStream.h>
- #include <UDrawingState.h>
-
- #include <ToolUtils.h>
-
- PP_Begin_Namespace_PowerPlant
-
-
- // ---------------------------------------------------------------------------
- // • LClipPicture Default Constructor [public]
- // ---------------------------------------------------------------------------
-
- LClipPicture::LClipPicture()
- {
- mPICT = nil;
- }
-
-
- // ---------------------------------------------------------------------------
- // • LClipPicture(const LClipPicture&) Copy Constructor [public]
- // ---------------------------------------------------------------------------
-
- LClipPicture::LClipPicture(
- const LClipPicture& inOriginal)
-
- : LView(inOriginal)
- {
- mPICT = inOriginal.mPICT;
- }
-
-
- // ---------------------------------------------------------------------------
- // • LClipPicture(LStream*) Stream Constructor [public]
- // ---------------------------------------------------------------------------
-
- LClipPicture::LClipPicture(
- LStream* inStream)
-
- : LView(inStream)
- {
- mPICT = nil;
- }
-
- // ---------------------------------------------------------------------------
- // • SetPicture
- // ---------------------------------------------------------------------------
-
- void
- LClipPicture::SetPicture(PicHandle inPict)
- {
- if (mPICT != nil)
- DisposeHandle((Handle)mPICT);
-
- mPICT = inPict;
-
- if (mPICT != nil)
- {
- Rect picFrame = (**mPICT).picFrame;
-
- ResizeImageTo((picFrame.right - picFrame.left) * 4,
- (picFrame.bottom - picFrame.top) * 4, false);
- }
-
- Refresh();
- }
-
- // ---------------------------------------------------------------------------
- // • DrawSelf [protected]
- // ---------------------------------------------------------------------------
- // Draw a Picture
-
- void
- LClipPicture::DrawSelf()
- {
- // If Picture resource exists, draw it. Otherwise, fill the
- // Frame with a light gray pattern and a one-pixel border.
-
- if (mPICT != nil)
- {
- SDimension32 imageSize;
- GetImageSize(imageSize);
-
- Rect pictureBounds;
- pictureBounds.left = 0;
- pictureBounds.top = 0;
- pictureBounds.right = (SInt16) imageSize.width;
- pictureBounds.bottom = (SInt16) imageSize.height;
-
- ::DrawPicture(mPICT, &pictureBounds);
- }
- else
- {
- Rect frame;
- CalcLocalFrameRect(frame);
- ::PenNormal();
- ::FillRect(&frame, &UQDGlobals::GetQDGlobals()->ltGray);
- ::FrameRect(&frame);
- }
- }
-
-
- PP_End_Namespace_PowerPlant
-